<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>ITAdmin | 找回密码</title>

    <link href="/static/css/bootstrap.min.css" rel="stylesheet">
    <link href="/static/font-awesome/css/font-awesome.css" rel="stylesheet">
    <link href="/static/css/animate.css" rel="stylesheet">
    <link href="/static/css/style.css" rel="stylesheet">
    <link href="/static/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
    <link rel="shortcut icon" href="/static/img/logo.ico" />

</head>

<body class="gray-bg">

    <div class="passwordBox animated fadeInDown">
        <div class="row">

            <div class="col-md-12">
                <div class="ibox-content">

                    <h2 class="font-bold">找回密码</h2>

                    <p>
                        请输入您注册的电子邮箱.
                    </p>

                    <div class="row">

                        <div class="col-lg-12">
                            <form class="m-t" role="form">
                                <div class="form-group">
                                    <input type="email" class="form-control" placeholder="邮箱地址" required="" id="email">
                                </div>

                                <button type="button" class="btn btn-primary block full-width m-b" id="rest">发送</button>
                                <a href="{% url 'index' %}">
                                    <small>返回登录</small>
                                </a>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <hr/>
        <div class="row">
            <div class="col-md-6">
                BY 大官人 QQ 375739049
            </div>
            <div class="col-md-6 text-right">
               <small>© 2017</small>
            </div>
        </div>
    </div>

</body>
<script src="/static/js/jquery-2.1.1.js"></script>
<script src="/static/js/plugins/sweetalert/sweetalert.min.js"></script>
<script type="text/javascript">
    $(function () {
         $.ajaxSetup({
            data: {csrfmiddlewaretoken: '{{ csrf_token }}'},
         });
        $("#rest").click(function () {
            if ($("#email").val() == '') {
                swal("错误", "邮箱不可为空", "error");
                return;
            }
            $.post("{% url 'retrievepassword' %}", {email:$("#email").val()}, function (data) {
                if (data.status == 1) {
                   location.href = "{% url 'index' %}";
               } else {
                   swal("错误", "邮箱不存在", "error");
               }
            });
        });
    });
</script>

</html>
